﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace System.Windows.Media.DirectShow
{
    public class PinsCollection : Collection<IPin>, IPinsEnumerable
    {

        #region IPinsEnumerable Members

        public IEnumerable<IPin> FindByDirection(PinDirection direction)
        {
            return this.Where(p => p.Direction == direction);
        }

        public IPin FindByName(string name)
        {
            return this.FirstOrDefault(p => p.Name == name);
        }

        public void DisconnectAndClear()
        {
            foreach (IPin p in this)
            {
                p.Disconnect();
            }
            this.Clear();
        }

        #endregion
    }
}
